/**
 * Created by duanq on 2017/3/31.
 */
import React from 'react';
import ReactDOM from 'react-dom';
import {Router,Route,IndexRedirect,hashHistory} from 'react-router';
import App from './auth/App';
/*import About from './auth/About';*/
import Home from './auth/Home';
import {LoginForm} from './auth/Login';
import {RegisterForm} from './auth/Register';

/*判断是否存在已登陆标记*/
const requireAuth =(nextState, replace)=>{
  if(!(sessionStorage.getItem("loginFlag"))){
      // Redirect to Home page if not login
      replace({ pathname: 'login' })
  }
};
ReactDOM.render(
    <Router history={hashHistory}>
        <Route path="/" component={App}>
            <IndexRedirect to="login" />
            <Route path="login" component={LoginForm}/>
            <Route path="register" component={RegisterForm}/>
            <Route path="home" component={Home} onEnter={requireAuth}/>
        </Route>
    </Router>
    ,document.getElementById('root')
);
